<template>
	<view class="content">
		<template v-if="isLoad">
			<my-head :head="head" />
			<my-page />
		</template>
	</view>
</template>

<script>
	import head from '@/components/head'
	import page from './my-page'
	export default {
		components: {
			'my-head': head,
			'my-page': page
		},
		data() {
			return {
				head: {},
				isLoad: false
			}
		},
		onShow (){
			// #ifdef MP-WEIXIN
			const result = this.$checkLogin()
			if(!result) return false
			// #endif
			
			this.head = {
				...this.$store.state.user_message
			}
			// 需要获取数据更新
			this.getAuthorDetail(this.head['loginname'])
			this.isLoad = true
		},
		methods: {
			async getAuthorDetail (author){
				let result = await this.$request.get('/user/'+author)
				let { data } = result
				if(result.success){
					this.head = {
						...this.head,
						score: String(data['score'])
					}
					uni.setStorage({
						key: 'user_msg',
						data: {
							...this.head
						}
					})
					this.$store.commit('add_user_message', {
						user_mg: {...this.head}
					})
				}
			}
		}
	}
</script>

